package com.zhongxi.guoyuan.view.rewardCoin;

import android.os.Bundle;
import android.util.SparseArray;

import com.zhongxi.guoyuan.base.BaseFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.BestPriceFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.NewGoodsFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.SalesGoodsFragment;

/**
 * Created by Administrator on 2017/10/14.
 */

public class ItemFragmentFactory {
    static SparseArray<BaseFragment> itemFragmentMap = new SparseArray();

    public static BaseFragment creatItem(int position, String id, String trim) {
        BaseFragment fragment = itemFragmentMap.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new NewGoodsFragment();
                    break;
                case 1:
                    fragment = new SalesGoodsFragment();
                    break;
                case 2:
                    fragment = new BestPriceFragment();
                    break;
            }
            if (fragment != null) {
                itemFragmentMap.put(position, fragment);
            }
        }
        Bundle args = new Bundle();
        args.putString("id", id);
        args.putString("trim", trim);
        fragment.setArguments(args);
        return fragment;
    }
}
